# #猜30以内的随机数
# from random import randint
#
# num=randint(1,30)
# while True:
#     guess = int (input("请输入一个数字："))
#     if guess >num:
#         print("猜大了")
#     elif guess <num:
#         print("猜小了")
#     else:
#         print("猜对了")
#         break

#打印九九乘法表
for i in range(1,10):
    for j in range(1,i+1):
        print(f"{j}*{i}={i*j}",end='\t')
    print()
#打印水仙花数
for num in range(100,1000):
    bai = num//100
    shi = (num//10)%10
    ge = num%10

    he = bai**3 + shi **3 +ge **3

    if he == num :
         print(num)
#打印100以内的质数
def is_zhishu(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    while i * i < n:
        if n % i == 0 or n % (i + 2) == 0:
            return False
        i += 6
    return True

    # 打印1到100之间的所有质数


#打印1到100之间的所有质数
for num in range(1,101):
    if is_zhishu(num):
        print(num)


#打印100以内的完数
for i in range(1,100+1):
    sum = 0
    for j in range(1,i):
        if  i%j ==0:
            sum +=j
    if sum == i:
        print(i)


#打印斐波那契数列前39项
# def fshulie(n):
#     if n <= 0:
#         return []
#     elif n==1:
#         return [0]
#     elif n==2:
#         return [0,1]
#     fib = [0,1]
#     for i in range(2,n):
#         fib.append(fshulie(i))
#     return fib
def fhsulie(n):
    if n <=0:
        return []
    elif n==1:
        return [0]
    elif n==2:
        return [0,1]
    fib = [0,1]
    for i in range(2,n):
        fib.append(fib[-1]+fib[-2])
    return fib
f = fhsulie(39)
print(f)
#打印斐波那契数列
# def fibonaqishulie(n):
#     if n <=0:
#         return []
#     if n <=1:
#         return [0]
#     if n <=2:
#         return [0,1]
#     fib = [0,1]
#     for i in range(2,n):
#         fib.append(fib[-1]+fib[-2])
#         print(fib)
#
# f = fibonaqishulie(90)
# print(f)


#打印菱形
for i in range(1,11+1,2):
    print (("*"*i).center(11))
for i in range(9,0,-2):
    print(("*"*i).center(11))
